package com.sqk.task0708;

import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import com.sqk.dxpro.utils.TProperties;

public class DxCountUvPvMapper extends Mapper<LongWritable, Text, Text, Text>{
	//任务8
	//in：产品ID|用户ID|PV(访问量)|产品类型
	//keyin：null
	//valuein：产品ID|用户ID|PV(访问量)|产品类型
	
	@Override
	protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, Text>.Context context)
			throws IOException, InterruptedException {
		String[] values = value.toString().split(TProperties.getValue("fileoutsplit"));
		//values[0]--产品ID
		//values[1]--用户ID
		//values[2]--PV(访问量)
		//values[3]--产品类型
		Text kk = new Text();
		kk.set(values[0]+TProperties.getValue("outfilesplit")+values[3]);
		//key----产品ID|产品类型
		Text vv = new Text();
		vv.set(values[1]+TProperties.getValue("outfilesplit")+values[2]);
		//value---用户ID|PV访问量
		context.write(kk, vv);
	}

}